Repository navigation
tools: conformance map checker (#7) - #66
Merged
Merged
Conversation
Add tools/ConformanceCheck, a console tool with no package references that parses every docs/conformance/*.md except README.md and enforces the row rules: six cells per row, a known status, tests on done rows, notes on n/a rows, unique clauses, and every cited test and implementing type present in tests/ and src/ (a line-level regex scan, no Roslyn). Violations print as docs/conformance/<file>.md:<line>: <message>; --summary prints a Markdown table of counts per status; --strict also requires tests and notes on partial rows. Exit 0 valid, 1 violations, 2 usage error. tests/ConformanceCheck.Tests drives the checker against one fixture repository per rule, asserting the exact violation, and against the real checkout, so dotnet test Broadside.Core.slnf fails when the map is wrong. docs/conformance/README.md documents the Tests and Implementing types cell formats, the rules, and how to run the checker locally and in CI. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The checker currently accepts headerless maps, malformed identifier lists, and invalid test references.
7 open findings
Require and validate a conformance map header · New Require cited test classes to contain indexed test methods · New Match only exact Fact and Theory attributes · New Strictly validate comma-separated test citations · New Fix command usability from nested checkout directories · New Seal the test class · New Fix command usability from nested checkout directories · New
What changed in this PR
Adds a .NET conformance-map checker that validates documentation rows, code references, and status rules.
Changes:
- Implements the checker CLI, parser, code index, validation, and summaries.
- Adds fixture-based tests and repository-wide validation.
- Documents formats and wires projects into solution builds.
| File | Description |
|---|---|
tools/ConformanceCheck/README.md |
Documents tool usage and behavior. |
tools/ConformanceCheck/Program.cs |
Implements CLI handling and output. |
tools/ConformanceCheck/ConformanceMap.cs |
Implements parsing, indexing, validation, and reporting. |
tools/ConformanceCheck/ConformanceCheck.csproj |
Defines the console project. |
tests/ConformanceCheck.Tests/ConformanceCheckerTests.cs |
Tests rules, summaries, and repository validation. |
tests/ConformanceCheck.Tests/ConformanceCheck.Tests.csproj |
Configures tests and fixture copying. |
tests/ConformanceCheck.Tests/Fixtures/valid/docs/conformance/x.md |
Provides a valid map fixture. |
tests/ConformanceCheck.Tests/Fixtures/valid/src/Foo/Foo.cs |
Provides valid source types. |
tests/ConformanceCheck.Tests/Fixtures/valid/tests/Foo.Tests/FooTests.cs |
Provides valid test identifiers. |
tests/ConformanceCheck.Tests/Fixtures/wrong-cell-count/docs/conformance/x.md |
Exercises malformed row detection. |
tests/ConformanceCheck.Tests/Fixtures/wrong-cell-count/src/Foo/Foo.cs |
Supplies fixture source types. |
tests/ConformanceCheck.Tests/Fixtures/wrong-cell-count/tests/Foo.Tests/FooTests.cs |
Supplies fixture tests. |
tests/ConformanceCheck.Tests/Fixtures/partial-without-tests/docs/conformance/x.md |
Exercises strict partial-row rules. |
tests/ConformanceCheck.Tests/Fixtures/partial-without-tests/src/Foo/Foo.cs |
Supplies fixture source types. |
tests/ConformanceCheck.Tests/Fixtures/partial-without-tests/tests/Foo.Tests/FooTests.cs |
Supplies fixture tests. |
tests/ConformanceCheck.Tests/Fixtures/na-without-notes/docs/conformance/x.md |
Exercises required n/a notes. |
tests/ConformanceCheck.Tests/Fixtures/na-without-notes/src/Foo/Foo.cs |
Supplies fixture source types. |
tests/ConformanceCheck.Tests/Fixtures/na-without-notes/tests/Foo.Tests/FooTests.cs |
Supplies fixture tests. |
tests/ConformanceCheck.Tests/Fixtures/missing-implementing-type/docs/conformance/x.md |
Exercises missing type detection. |
tests/ConformanceCheck.Tests/Fixtures/missing-implementing-type/src/Foo/Foo.cs |
Supplies known source types. |
tests/ConformanceCheck.Tests/Fixtures/missing-implementing-type/tests/Foo.Tests/FooTests.cs |
Supplies fixture tests. |
tests/ConformanceCheck.Tests/Fixtures/duplicate-clause/docs/conformance/x.md |
Exercises duplicate clause detection. |
tests/ConformanceCheck.Tests/Fixtures/duplicate-clause/src/Foo/Foo.cs |
Supplies fixture source types. |
tests/ConformanceCheck.Tests/Fixtures/duplicate-clause/tests/Foo.Tests/FooTests.cs |
Supplies fixture tests. |
tests/ConformanceCheck.Tests/Fixtures/done-without-tests/docs/conformance/x.md |
Exercises required done-row tests. |
tests/ConformanceCheck.Tests/Fixtures/done-without-tests/src/Foo/Foo.cs |
Supplies fixture source types. |
tests/ConformanceCheck.Tests/Fixtures/done-without-tests/tests/Foo.Tests/FooTests.cs |
Supplies fixture tests. |
tests/ConformanceCheck.Tests/Fixtures/done-with-missing-test/docs/conformance/x.md |
Exercises unresolved test detection. |
tests/ConformanceCheck.Tests/Fixtures/done-with-missing-test/src/Foo/Foo.cs |
Supplies fixture source types. |
tests/ConformanceCheck.Tests/Fixtures/done-with-missing-test/tests/Foo.Tests/FooTests.cs |
Provides a non-test method reference. |
tests/ConformanceCheck.Tests/Fixtures/bad-status/docs/conformance/x.md |
Exercises invalid status detection. |
tests/ConformanceCheck.Tests/Fixtures/bad-status/src/Foo/Foo.cs |
Supplies fixture source types. |
tests/ConformanceCheck.Tests/Fixtures/bad-status/tests/Foo.Tests/FooTests.cs |
Supplies fixture tests. |
docs/conformance/README.md |
Defines row formats, rules, and invocation. |
Broadside.slnx |
Adds checker and test projects. |
Broadside.Core.slnf |
Includes checker tests in core testing. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+89
to
+90
| bool isHeader = i + 1 < lines.Count && IsSeparator(SplitCells(lines[i + 1].Trim())); | ||
| if (isHeader) |
| } | ||
|
|
||
| /// <summary>Whether a type named <paramref name="fullName"/> (<c>Namespace.Class</c>) is declared under <c>tests/</c>.</summary> | ||
| public bool HasTestClass(string fullName) => _testClasses.ContainsKey(fullName); |
Comment on lines
+316
to
+317
| [GeneratedRegex(@"\[\s*(?:[A-Za-z_]\w*\.)*\w*(?:Fact|Theory)(?:Attribute)?\s*[\](,]")] | ||
| private static partial Regex TestAttribute(); |
Comment on lines
+547
to
+559
| foreach (Match match in matches) | ||
| { | ||
| string identifier = match.Groups[1].Value.Trim(); | ||
| if (identifier.Length == 0) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| identifiers.Add(identifier); | ||
| } | ||
|
|
||
| string remainder = Backticked().Replace(cell, string.Empty); | ||
| return remainder.All(static c => c == ',' || char.IsWhiteSpace(c)); |
| ## Running the checker | ||
|
|
||
| ```sh | ||
| dotnet run --project tools/ConformanceCheck -- --summary # from anywhere inside the checkout |
| /// One fixture repository per rule under <c>Fixtures/</c> (copied next to the test assembly), each with a <c>docs/conformance/x.md</c>, | ||
| /// a <c>tests/Foo.Tests/FooTests.cs</c> and a <c>src/Foo/Foo.cs</c>, plus a run against the real checkout so <c>dotnet test</c> fails when the map is wrong. | ||
| /// </summary> | ||
| public class ConformanceCheckerTests |
| Validates the conformance map in `docs/conformance/`. The rules, the cell formats and how to run it are in [docs/conformance/README.md](../../docs/conformance/README.md); this file is only the tool's own notes. | ||
|
|
||
| ```sh | ||
| dotnet run --project tools/ConformanceCheck -- --summary # from anywhere inside the checkout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Closes #7
Summary
Adds
tools/ConformanceCheck(console, net10.0, root namespaceBroadside.Tools.ConformanceCheck, no package references) andtests/ConformanceCheck.Tests, and documents the row formats and rules indocs/conformance/README.md.The tool.
ConformanceMap.csholds the parser, the code index and the rules as public types;Program.csis argument parsing and console output. CLI:--root <dir>(default: walk up from the current directory to the folder containingBroadside.slnx),--summary(Markdown table of row counts per status per file, plus a total),--strict(also failpartialrows with an empty Tests or Notes cell). Exit 0 when valid, 1 when any rule fails (one line per violation,docs/conformance/<file>.md:<line>: <message>), 2 for a usage error or a root withoutdocs/conformance.Rules enforced over every
docs/conformance/*.mdexceptREADME.md:Clause | Title | Status | Implementing types | Tests | Notes.not started,partial,done,n/a.donerow names at least one test.n/arow has a non-empty Notes cell.[Fact]/[Theory]method undertests/**/*.cs.class,struct,interface,enumorrecordundersrc/**/*.cs.--strictonly: apartialrow names at least one test and has a non-empty Notes cell.The code lookups are a line-level regex scan (
namespace, type declarations, attributed method declarations), not Roslyn;bin,objandFixturesdirectories are skipped.Cell formats (documented in
docs/conformance/README.md):`Namespace.Class.Method`or a test class`Namespace.Class`. The class is the one that directly declares the method, in the namespace its file declares; the method must carry[Fact]or[Theory].`CosDictionary`, `CosLexer`), no namespace, no type arguments.The tests. Nine fixture repositories under
tests/ConformanceCheck.Tests/Fixtures/<case>/(each adocs/conformance/x.md,tests/Foo.Tests/FooTests.cs,src/Foo/Foo.cs; the.csfiles areCompile Removed and copied to output), one test per case asserting the exact violation line: valid map,donewithout tests,donenaming a non-test method, bad status, wrong cell count,n/awithout notes, duplicate clause, missing implementing type, andpartialwithout tests/notes (passes by default, two violations under--strict). Plus a summary-format test, a missing-directory test, andRepository_conformance_map_is_valid, which runs the checker against the checkout on everydotnet test Broadside.Core.slnf.Wiring. Tool under
/tools/and test project under/tests/inBroadside.slnx; test project added toBroadside.Core.slnf. The CI job from #4 invokesdotnet run --project tools/ConformanceCheck -- --root . --summary, verified below from the repo root.Not done. No existing conformance file needed changes: all 207 rows are
not startedand the checker reports zero violations. NoPublicAPI.Unshipped.txtchanges (nothing undersrc/changed).Deliverables
docs/conformance/README.mddocuments the formats and rulesPublicAPI.Unshipped.txtunchanged (nosrc/changes)Public API changes
none
Verification
dotnet build Broadside.slnx -warnaserror -p:BroadsideBuildPlatformBackends=falseDiffEngine_Disabled=true dotnet test Broadside.Core.slnfdotnet run --project tools/ConformanceCheck -- --root . --summary(exit 0)dotnet run --project tools/ConformanceCheck -- --root tests/ConformanceCheck.Tests/Fixtures/done-with-missing-test --summary(exit 1)Also checked by hand that the index resolves real code: a temporary row citing
`Broadside.Tests.CorpusSmokeTests.Well_formed_file_has_pdf_header_and_eof_marker`,`Broadside.Tests.CorpusSmokeTests`and`AssemblyMarker`passed, and a sibling row with bare text in the Tests cell and a typeNopeproduced exactly two violations. The row was reverted before committing.🤖 Generated with Claude Code